home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / settosize.sty < prev    next >
Text File  |  1993-02-17  |  1KB  |  51 lines

  1. %%% The user needs to be able to specify the width for text, and
  2. %%% use the largest point size necessary to fill that width.
  3. %%%
  4. %%% After macros by Phil Taylor January 1993; 
  5. %%% converted to LaTeX style file (needs NFSS) and changed syntax 
  6. %%% by Sebastian Rahtz, February 1993.
  7.  
  8. %%% \Fontname: like \fontname, but voids any size specifier
  9. %%%  Usage:   \Fontname \font {} %%% don't omit {} !!!
  10.  
  11. \edef \Fontname 
  12.      {\noexpand \expandafter \noexpand \stripsize \noexpand \fontname \space}
  13. \def \stripsize #1 #2#{#1}
  14.  
  15. \newcount \pts@f@r
  16. \newdimen \set@width
  17.  
  18. \def\massage@fontname#1 #2:{\def\curr@fontname{#1}}
  19.  
  20. \def \scaletowidth#1#2{%
  21.     \set@width #1 
  22.     \edef\f@name{\fontname\font\space:}%
  23.     \expandafter\massage@fontname\f@name
  24.     \pts@f@r \f@size
  25.     \setbox 0 = \hbox{#2}%
  26.      \ifdim \wd 0 < \set@width
  27.     \def\@increment{1}%
  28.     \def\@test{<}%
  29.      \else
  30.     \def\@increment{-1}%
  31.     \def\@test{>}%
  32.      \fi
  33.      \loop
  34.        \font\temp@font=\curr@fontname\space at \the\pts@f@r pt
  35.     \setbox 0 = \hbox{{\temp@font #2}}%
  36.         \message {\curr@fontname->\the \pts@f@r...}%
  37.         \ifdim \wd 0 \@test \set@width
  38.            \advance \pts@f@r by \@increment
  39.      \repeat
  40.      \advance \pts@f@r by -\@increment
  41.      \message {The calculated font size is \the \pts@f@r pt}%
  42.      \font\temp@font=\curr@fontname\space at \the\pts@f@r pt
  43.      \hbox to \set@width {\hss{\temp@font #2}\hss}%
  44.     }
  45. \endinput
  46.  
  47.  
  48. Example:
  49.  
  50. \scaletowidth{50cm}{Now is the time for the Party}
  51.